//
//  OYTextView.swift
//  weiboCopycat
//
//  Created by Orange Yu on 2016/12/9.
//  Copyright © 2016年 Orange Yu. All rights reserved.
//

import UIKit

class OYTextView: UITextView {

     // MARK: -控件的懒加载
    lazy var placeholderLabel: UILabel = {
        let label = UILabel()
        label.text = "分享新鲜事..."
        label.textColor = UIColor.lightGray
        
//        self.font = label.font
        
        return label
    }()
    
    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
    
        setupUI()
    }
    
    var placeHolder: String? {
        didSet {
            placeholderLabel.text = placeHolder
        }
    }
    
     // MARK: -添加、布局子控件
    func setupUI() {
        
        addSubview(placeholderLabel)
        
        //布局子控件
        placeholderLabel.translatesAutoresizingMaskIntoConstraints = false
        addConstraint(NSLayoutConstraint(item: placeholderLabel, attribute: .left, relatedBy: .equal, toItem: self, attribute: .left, multiplier: 1, constant: 8))
        addConstraint(NSLayoutConstraint(item: placeholderLabel, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1, constant: 8))
        
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    

}
